Parametricity and Unboxing with Unpointed Types

نویسندگان

  • John Launchbury
  • Ross Paterson
چکیده

In lazy functional languages, .l. is typically an element of every type. While this provides great flexibility, it also comes at a cost. In this paper we explore the consequences of allowing unpointed types in a lazy functional language like HaskeU. We use the type (and class) system to keep track of pointedness, and show the consequences for parametricity and for controlling evaluation order and unboxing. 1 I n t r o d u c t i o n Ever since Scott and others showed how to use pointed CPOs (i.e. with bottoms) to give meaning to general recursion, both over values (including functions), and over types themselves, functional languages seem to have been wedded to the concept. Languages like ttaskell [5] model types by appropriate CPOs and, because non-terminating computations can happen at any type, all the CPOs are pointed. This gives significant flexibility. In particular, values of any type may be defined using recursion. 1.1 P a r a m e t r i c i t y There are associated costs, however. When reasoning about programs, one must also allow for the possibility of non-termination, even if a function is in fact total. Similarly, the general parametricity theorems that follow from polymorphic types (popularized by Wadler as "Theorems for Free" [15]) are rather weaker than in the pure simply-typed A-calculus. Parametricity was introduced by Reynolds to express the limits on behaviour that polymorphism induces [11]. For example, a function that has the type V a. ot ---* a can do nothing interesting to its argument: it can only return it. However, in a language like Haskell in which 3_ is an element of every type, a function of type V a. a ---* a could also ignore its argument, and call itself in infinite recursion, i.e. return .l.. To allow for this, parametricity results must be weakened; the usual treatment is to require that all relations be strict (and inductive--if elements of two chains are related, then so are their limits). For example, consider the following polymorphic typings in which the quantification is given explicitly: r eve r se : V a . L i s t a --, L i s t a f o l d r : V (x, ft. (e~ ~ fl ~ /3) --*/3 ~ L i s t a --* fl

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Type-Preserving Flow Analysis and Interprocedural Unboxing (Extended Version)

Interprocedural flow analysis can be used to eliminate otherwise unnecessary heap allocated objects (unboxing), and in previous work we have shown how to do so while maintaining correctness with respect to the garbage collector. In this paper, we extend the notion of flow analysis to incorporate types, enabling analysis and optimization of typed programs. We apply this typed analysis to specify...

متن کامل

Unboxed Values as First Class Citizens in a Non-Strict Functional Language

The code compiled from a non-strict functional program usually manipulates heap-allocated boxed numbers. Compilers for such languages often go to considerable trouble to optimise operations on boxed numbers into simpler operations on their unboxed forms. These optimisations are usually handled in an ad hoc manner in the code generator, because earlier phases of the compiler have no way to talk ...

متن کامل

ar X iv : 1 20 3 . 19 86 v 1 [ cs . P L ] 9 M ar 2 01 2 Type - Preserving Flow Analysis and Interprocedural Unboxing Extended

Interprocedural flow analysis can be used to eliminate otherwise unnecessary heap allocated objects (unboxing), and in previous work we have shown how to do so while maintaining correctness with respect to the garbage collector. In this paper, we extend the notion of flow analysis to incorporate types, enabling analysis and optimization of typed programs. We apply this typed analysis to specify...

متن کامل

Parametricity as Isomorphism

We investigatea simple form of parametricity, based on adding \abstract" copies of pre-existing types. Connections are made with the Reynolds-Ma theory of parametricity by logical relations, with the theory of parametricity via dinaturality, and with the categorical notion of equivalence.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1996